package com.grantha.util;

public class BarcodeGenerator {
	public static boolean generateBarcode(String from, String to) {
		int start, end, addi;
		try {
			DB.update("delete from barcode");
			start = Integer.parseInt(from);
			end = Integer.parseInt(to);
			addi = ((end - start) + 1) % 4;
			if (addi == 1)
				end += 3;
			if (addi == 2)
				end += 2;
			if (addi == 3)
				end += 1;
			int j = 0;
			for (int i = start; i <= end; i += 4) {
				++j;
				DB.update("insert into barcode values ('" + Integer.toString(j)
						+ "','" + Integer.toString(i) + "', '"
						+ Integer.toString(i + 1) + "',  '"
						+ Integer.toString(i + 2) + "', '"
						+ Integer.toString(i + 3) + "')");

			}
			return true;

		} catch (Exception e) {
			return false;
		}

	}
}
